#ifndef LEETCODE_CN_CPP_PROBLEMS_62_H
#define LEETCODE_CN_CPP_PROBLEMS_62_H

#include <algorithm>
#include <array>

using namespace std;

namespace problem_62
{

class Solution
{
private:
    array<array<int, 100>, 100> grid;
    void resetGrid(int m, int n)
    {
        for (int i = 0; i < n; ++i)
        {
            for (int j = 0; j < m; ++j)
            {
                if (i == 0 || j == 0)
                {
                    grid[i][j] = 1;
                }
                else
                {
                    grid[i][j] = 0;
                }
            }
        }
    }

public:
    int uniquePaths(int m, int n)
    {
        resetGrid(m, n);
        for (int i = 1; i < n; ++i)
        {
            for (int j = 1; j < m; ++j)
            {
                grid[i][j] += grid[i - 1][j] + grid[i][j - 1];
            }
        }
        return grid[n - 1][m - 1];
    }
};

} // namespace problem_62

#endif //LEETCODE_CN_CPP_PROBLEMS_62_H
